﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Collections;
using GPCSC.Web;

namespace GPCSC.Web.CM
{
    public partial class WebForm1 : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            df();
        }

        /// <summary>
        /// 为人员表分部门 赋值
        /// </summary>
        protected void df()
        {
            Hashtable htable = new Hashtable();
            DataSet dspost = new DataSet();
            SQLServerDAL.databyhtable dtable = new SQLServerDAL.databyhtable();
            dspost = new SqlReadXml().ReaderDataSet("sel_POST_all", htable);

            foreach (DataRow dr in dspost.Tables[0].Rows)
            {
                Hashtable htabs = new Hashtable();
                htabs.Add("@CL_POSTID_PK", dr["CL_POST_SOID"].ToString());
                DataSet dst = new DataSet();
                dst = new SqlReadXml().ReaderDataSet("sel_user_bypost", htabs);
                int m = 1;
                if (dst.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < dst.Tables[0].Rows.Count; i++)
                    {
                        Hashtable hte = new Hashtable();
                        hte.Add("number", m);
                        dtable.databyhtables(hte, "update", "CL_USER_S", "CL_USER_SOID", dst.Tables[0].Rows[i]["CL_USER_SOID"].ToString());
                        m++;
                    }
                }

            }
            //DataSet ds = new SqlReadXml().ReaderDataSet("sel_user_all", htable);
            //SQLServerDAL.databyhtable dtable = new SQLServerDAL.databyhtable();
            //if (ds != null)
            //{
            //    if (ds.Tables.Count > 0)
            //    {
            //        if (ds.Tables[0].Rows.Count > 0)
            //        {
            //            int sd = ds.Tables[0].Rows.Count;
            //            int m = 1;
            //            for (int i = 0; i < sd; i++)
            //            {
            //                if (ds.Tables[0].Rows[i]["CL_POSTID_PK"].ToString() == ds.Tables[0].Rows[i + 1]["CL_POSTID_PK"].ToString())
            //                {

            //                    htable.Clear();
            //                    htable.Add("number", m);
            //                    dtable.databyhtables(htable, "update", "CL_USER_S", "CL_USER_SOID", ds.Tables[0].Rows[i]["CL_USER_SOID"].ToString());
            //                    m++;
            //                }
            //                else
            //                {
            //                    m = 1;
            //                    htable.Clear();
            //                    htable.Add("number", m);
            //                    dtable.databyhtables(htable, "update", "CL_USER_S", "CL_USER_SOID", ds.Tables[0].Rows[i]["CL_USER_SOID"].ToString());
            //                    m++;
            //                }
            //            }
            //        }
            //    }

            //}
        }
    }
}